//------------------------------------------------------------------------
// <copyright file="MetaDataFile.cs" company="DevDir">
//   Copyleft (c) DevDir. No rights reserved.
// </copyright>
// <author>Nikita Sharov</author>
//------------------------------------------------------------------------

namespace DevDir.Mp3
{
  using System.IO;
  using System.Collections.Generic;
  
  /// <summary>
  /// Mighty MetaDataFile.
  /// </summary>
  public class MetaDataFile
  {
    private FileInfo fileData;
    private TagLib.File tagLibFile;
    
    // TODO: Improve naming.
    private List<MetaData> items = new List<MetaData>();
    
    public MetaDataFile()
    {
    }

    public MetaDataFile(FileInfo fileInfo)
    {
      this.FileData = fileInfo;
    }

    public FileInfo FileData
    {
      get 
      { 
        return this.fileData; 
      }

      set 
      {
        if (this.fileData != value)
        {
          this.fileData = value;
          this.OnFileDataChanged();
        }
      }
    }

    public List<MetaData> Items
    {
      get { return this.items; }
    }

    protected virtual void OnFileDataChanged()
    {
      this.tagLibFile = TagLib.File.Create(this.fileData.FullName);
      this.items.Clear();
      this.items.Add(MetaData.Create(this.tagLibFile));
    }
  }
}
